package com.feihao.zhou.mapper;

import com.feihao.zhou.bean.Classes;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface OneToMany {

    //查询所有班级
    @Select("select * from classes")
    @Results({
            @Result(column = "id", property = "id"),
            @Result(column = "name", property = "name"),

            @Result(
                    property = "students", javaType = List.class,
                    column = "id",
                    many = @Many(select = "com.feihao.zhou.mapper.StudentMapper.selectAllStudentById")
            )
    })
    List<Classes> selectAllClasses();
}
